package utilities;

public class Utilities {
	
	public static int getNextNumberInArray(int currentNumber, Object[] numbers){
		int nextSeat = -1;
		
		for(int i=0; i<numbers.length; i++){			
			
			if(numbers[i].equals(currentNumber)){
				//found the active player
				if(numbers.length - 1 == i){
					//next player is the first index
					nextSeat = (Integer)numbers[0];
				}else{
					nextSeat = (Integer) numbers[i+1];
				}		
			}			
		}
		return nextSeat;
	}
	
	
	public static int getPrevNumberInArray(int currentNumber, Object[] numbers){
		// this method will fail is the current seat is more negative than the lowest seat. add crappy fix like above
		int prevSeat = -1;
		
		for(int i=0; i<numbers.length; i++){
			if(numbers[i].equals(currentNumber)){
				//found the active player
				if(i == 0){
					//prev player is the last index
					prevSeat = (Integer)numbers[numbers.length - 1];
				}else{
					prevSeat = (Integer) numbers[i-1];
				}		
			}
		}
		return prevSeat;
	}
	
	
	
}
